package main

import "fmt"

// 结构体定义
type Books struct {
	title   string
	author  string
	subject string
	book_id int
}

func main() {
	// 创建一个新的结构体
	fmt.Println(Books{"我是金正恩", "金正恩", "politics", 1})
	// 使用key => value格式
	fmt.Println(Books{
		title:   "我的奋斗",
		author:  "希特勒",
		subject: "politics",
		book_id: 2,
	})
	// 未定义的值为默认值
	fmt.Println(Books{
		title: "未知的书",
	})
	// 访问结构体成员
	var Books1 Books
	Books1.author = "王恒"
	fmt.Println(Books1.author)
	// 结构体作为函数参数
	structOperation(Books1)
	// 结构体指针
	var struct_pointer *Books
	struct_pointer = &Books1
	struct_pointer.author = "希特勒"
	fmt.Println(struct_pointer.author)
	fmt.Println(Books1.author)

}

func structOperation(book1 Books) {
	fmt.Println(book1)
}
